﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using X.Web;

namespace X.WebSite.Admin.Ad
{
    public partial class List : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }
        }

        void BindGrid()
        {
            gvAdList.DataSource = Bll.Ad.GetAllList();
            gvAdList.DataBind();
        }

        protected void gvAdList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = int.Parse(gvAdList.DataKeys[e.RowIndex].Value.ToString());

            Bll.Ad.Delete(id);

            BindGrid();
        }
    }
}